<template>
     <div class="tag_box">
      <ul class="no1">
        <li v-for="icon in iconList1" :key="icon.id" >
          <a to="/radioTopList" @click.self="iconBtn(icon.id)" :class="{clickTag:selectTag==icon.id}">
            <div
              class="tag_icon"
              :style="`background-image: url(${icon.picMacUrl})`"
            ></div>
            <span>{{icon.name}}</span>
          </a>
        </li>
      </ul>
      <ul class="no2" v-show="page">
        <li v-for="icon in iconList2" :key="icon.id">
          <a to="/radioTopList" @click.self="iconBtn(icon.id)" :class="{clickTag:selectTag==icon.id}">
            <div
              class="tag_icon"
              :style="`background-image: url(${icon.picMacUrl})`"
            ></div>
            <span>{{icon.name}}</span>
          </a>
        </li>
      </ul>
      <div class="dot">
        <span @click="leftBtn" ref="leftDot"></span>
        <span @click="rightBtn" ref="rightDot"></span>
      </div>
      <div class="left_btn btn" @click="leftBtn"></div>
      <div class="right_btn btn" @click="rightBtn"></div>
    </div>
</template>

<script>
import {reqRadioClass} from "../../../api/index"

export default {
name:"RadioCategory",
data(){
  return{
    page: 0,
    iconList1:[],
    iconList2:[],
    selectTag:'',
  }
},
async mounted(){
  const result=await reqRadioClass()
  this.iconList1=result.categories.slice(0,18)
  this.iconList2=result.categories.slice(18)
},
 methods: {
    rightBtn() {
      this.page = 1;
      this.$refs.rightDot.style.backgroundColor = "rgb(186, 35, 0)";
      this.$refs.leftDot.style.backgroundColor = "rgb(223, 223, 223)";
    },
    leftBtn() {
      this.page = 0;
      this.$refs.leftDot.style.backgroundColor = "rgb(186, 35, 0)";
      this.$refs.rightDot.style.backgroundColor = "rgb(223, 223, 223)";
    },
    iconBtn(id){   
        this.selectTag=id
        this.$router.push({name:"RadioTopList",params:{id}})
    }
  },
}
</script>
  
<style lang="less">
.tag_box {
    position: relative;
    // border: 1px solid black;
    height: 194px;
    margin-left: -33px;
    a{
      box-sizing: border-box;
    }
    .no2 {
      // display: none;
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: #fff;
    }
    li {
      float: left;
      // border:1px solid red;
      margin-left: 33px;
      margin-bottom: 25px;
      height: 72px;
      a {
        width: 70px;
        height: 70px;
        float: left;
        z-index: 99;
        text-align: center;
        .tag_icon {
          pointer-events:none;//事件穿透
          margin: 0 auto;
          width: 48px;
          height: 48px;
          background-position: -5px -5px;
          // border: 1px solid blue;
        }
      }
    }
    .dot {
      position: absolute;
      height: 20px;
      left: 50%;
      bottom: 0px;
      span {
        margin: 0 10px;
        display: inline-block;
        width: 7px;
        height: 7px;
        background-color: rgb(223, 223, 223);
        border-radius: 50%;
        &:hover {
          background-color: rgb(186, 35, 0);
        }
      }
    }
    .btn {
      position: absolute;
      top: 50%;
      margin-top: -15px;
      width: 20px;
      height: 30px;
      background: url(https://s2.music.126.net/style/web2/img/index_radio/radio_slide.png?568cdb029122b1738f3571fb4e5e669a)
        no-repeat;
    }
    .right_btn {
      right: -35px;
      background-position: -30px -30px;
    }
    .left_btn {
      background-position: 0px -30px;
    }
    .clickTag{
      color:rgb(219, 94, 94);
      border:2px solid rgb(219, 94, 94);
      border-radius:5px;
      .tag_icon{
        background-position:-66px -5px;
      }
    }
  }
</style>